_spBodyOnLoadFunctionNames.push("removeLimitedAccess");

//removes limited access entires from ui
function removeLimitedAccess() {
	//never process unless this is a permissions page
	if ($('form[action*="user.aspx"]').length || $('form[action*="User.aspx"]').length) {
		//if the user requests to show limited access then skip processing
		if (getURLParam('ShowLimitedAccess') == null) {
			//loop all rows in the permissions table
			$("#ctl00_PlaceHolderMain_rptrUsers tr").each(function(){
				//if limited access exists
				if($(this).text().indexOf('Limited Access') > -1) {
					//if this is the only permission listed
					if($(this).text().indexOf(',') == -1 ) { 
						$(this).remove();
						hasLimitedAccess = true;
					} else {
						//if there are multiple permissions then just remove limited access
						$(this).text(function(index, originalText) { 
							var find = [", Limited Access", "Limited Access,"]; 
							var replace = ["", ""]; 
							$(this).html($(this).html().replaceArray(find, replace));   
						}); 
					}
				}
			});

			if (hasLimitedAccess) {
				if (document.location.href.indexOf('?') == -1) {
					var location = document.location.href + '?ShowLimitedAccess=true';
				} else {
					var location = document.location.href + '&ShowLimitedAccess=true';
				}
				$(".ms-listdescription").append("<p><strong>Needing to edit Limited Access entries is very rare.</strong>  If you understand the impact and need to view or edit Limited Access entries, <a href='"+ location +"'>click here</a> to show them.</p>");
			}
		}
	}
}